Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adde support for v2 api Settings #77

Merged
merged 5 commits into from
Jan 5, 2024

Conversation

wouter-evolane
Copy link

added v2 settings support and tests

@dynatrace-cla-bot
Copy link
Member

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Wouter De Troyer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Dynatrace-James-Kitson
Copy link
Collaborator

Thank you for your contributions!

Overall it looks like a good start on the settings API. There's a few small issues around formatting and consistency which we can clean up. I'll make a few notes, if you'd like to work on those yourself otherwise I can merge and make the changes myself.

Copy link
Collaborator

@Dynatrace-James-Kitson Dynatrace-James-Kitson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some formatting using black also should be done (see the contributions guide doc about this).

Overall a very good start and can be merged, but will need some changes before inclusion in a release. I'll give some time if you'd like to make some more changes otherwise I can merge and do on top.

from dynatrace.pagination import PaginatedList
import json
import logging
from http.client import HTTPConnection # py3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is used anywhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused imports

def __init__(self, http_client: HttpClient):
self.__http_client = http_client

def list(self,schema_id: Optional[str] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to update these method names to 'list_objects' etc... The issue would be that this API also lets you list and view 'schemas' so we'd need to name them a bit more clearly to differentiate.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed methods

}
return PaginatedList(Settings, self.__http_client, target_url=self.ENDPOINT, list_item="items", target_params=params)

def post(self,external_id,object_id,schema_id,schema_version,scope, value,validate_only):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above the name should clarify what we're interacting with as well as we want to name them after the action not the HTTP method.

e.g. create_object

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed methods

return self.__http_client.make_request(path=f"{self.ENDPOINT}/{object_id}", method="DELETE")

class Settings(DynatraceObject):
value = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed/used anywhere.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed value=none

# Mandatory
self.objectId: str = raw_element["objectId"]
self.value: str = raw_element["value"]
def to_json(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the motivation for this but I don't think we'd include this as all it is is a 'getter' that returns the value attribute. If this is needed they can just access the 'value' attribute of the settings object. We don't have anything like this for other objects. to_json() could also confuse someone if they expected the whole json including the object id.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed to_json

* renamed methods
* removed unnecessary methods
* updated tests for method rename
Copy link

sonarcloud bot commented Nov 29, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Dynatrace-James-Kitson Dynatrace-James-Kitson merged commit 68b8acd into dynatrace-oss:main Jan 5, 2024
3 of 16 checks passed
@Dynatrace-James-Kitson
Copy link
Collaborator

I've been adding to this commit this week. Looking through more and testing I've made a few changes to have it align better with the rest of this project and am also deciding on some details about the 'settings object' create behavior to make it line up properly with the API while also being usable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants